@Test
	public void testWritevStdout() throws Exception {
		try (Transaction tx = program.openTransaction("Initialize")) {
			Address data = space.getAddress(0x00400800);
			ByteBuffer buf = ByteBuffer.allocate(64).order(ByteOrder.LITTLE_ENDIAN);

			Address strHello = data.add(buf.position());
			buf.put(BYTES_HELLO);
			Address endHello = data.add(buf.position());
			Address iov = data.add(buf.position());
			buf.putLong(strHello.getOffset());
			buf.putLong(endHello.subtract(strHello));
			int posIov1base = buf.position();
			buf.putLong(0);
			int posIov1len = buf.position();
			buf.putLong(0);
			Address strWorld = data.add(buf.position());
			buf.put(BYTES_WORLD);
			Address endWorld = data.add(buf.position());
			// Backpatch
			buf.putLong(posIov1base, strWorld.getOffset());
			buf.putLong(posIov1len, endWorld.subtract(strWorld));

			asm.assemble(start,
				"MOV RAX," + Syscall.WRITEV.number,
				"MOV RDI," + EmuUnixFileDescriptor.FD_STDOUT,
				"LEA RSI,[0x" + iov + "]",
				"MOV RDX,2",
				"SYSCALL",
				"MOV RAX," + Syscall.GROUP_EXIT.number,
				"MOV RDI,0",
				"SYSCALL");
			block.putBytes(data, buf.array());
		}

		LinuxAmd64PcodeEmulator emu = prepareEmulator();
		PcodeThread<byte[]> thread = launchThread(emu, start);

		// Capture stdout into a byte array
		ByteArrayOutputStream stdout = new ByteArrayOutputStream();
		emu.syscalls.putDescriptor(EmuUnixFileDescriptor.FD_STDOUT,
			new IOStreamEmuUnixFileHandle(emu, program.getCompilerSpec(), null, stdout));

		// Step through writev and verify return value and actual output effect
		thread.stepInstruction(5);

		assertEquals(BYTES_HW.length,
			arithmetic.toLong(thread.getState().getVar(regRAX, Reason.INSPECT), Purpose.OTHER));
		assertArrayEquals(BYTES_HW, stdout.toByteArray());

		stepGroupExit(thread);
	}
These are a subset of the linux_amd64 system call numbers as of writing this test, but it
doesn't really matter as long as the user program and syscall library agree.
Ghidra/Features/SystemEmulation/src/test/java/ghidra/pcode/emu/linux/EmuLinuxAmd64SyscallUseropLibraryTest.java